package com.stone.delay.config;

import com.stone.delay.app.queue.RedisDelayQueue;
import com.stone.delay.app.runner.RedisDelayQueueRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * redis延时队列自动配置
 *
 * @author Mr_wenpan@163.com 2021/11/15 22:43
 */
@Configuration
public class RedisDelayQueueAutoConfiguration {

    private final static String ENABLE_DELAY_QUEUE_PREFIX = "stone.redis.delay-queue";

    @Bean
    @ConditionalOnBean(RedisDelayQueue.class)
    @ConditionalOnProperty(prefix = ENABLE_DELAY_QUEUE_PREFIX, name = "enable", havingValue = "true")
    public RedisDelayQueueRunner redisDelayedQueueInit() {
        return new RedisDelayQueueRunner();
    }

}
